package com.sinafenqi.designDemo.proxy.jdkDynamic;

import sun.misc.ProxyGenerator;

import java.io.*;

/**
 * @author hujinsheng
 * @project DesignModeproxy
 * @create 2017-11-06 16:28
 **/
public class DynamicProxyTest {

    public static void main(String[] args) throws IOException {
        LiuDeHuaProxy proxy = new LiuDeHuaProxy();
        Person p = proxy.getProxy();
        p.sing("冰雨");
        p.dance("一二三四五");
        String name = "LiuDeHuaProxy";
        byte[] data = ProxyGenerator.generateProxyClass( name, new Class[] { Person.class } );
        try
        {
            FileOutputStream out = new FileOutputStream( "D:\\"+name + ".class" );
            out.write( data );
            out.close();
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
    }


}
